#ifndef _________MOTOR_FOC_MANAGER_H_________
#define _________MOTOR_FOC_MANAGER_H_________

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

#include "motor_foc.h"
#include "motor_hall.h"
#include "motor_adc.h"
#include "motor_pwm.h"

typedef struct motor_foc_manager_t {
	FOC_Type foc;
	HallHandler_t hall_handler;
    HallConfig_t hall_config;
    uint8_t is_initialized;
}Motor_FOC_Manager;

extern Motor_FOC_Manager g_foc_manager;

#define FOC_CMD_BUFFER_SIZE 64

extern uint8_t g_foc_recv_data[FOC_CMD_BUFFER_SIZE];
extern uint16_t g_foc_recv_data_len;


void FOC_Manager_Init(Motor_FOC_Manager* manager);
void FOC_Manager_Update(Motor_FOC_Manager* manager);
void FOC_Manager_SetTarget(Motor_FOC_Manager* manager, MotorModeType_e mode, int16_t target);
void FOC_Manager_Enable(Motor_FOC_Manager* manager, uint8_t enable);
uint8_t FOC_Manager_IsReady(Motor_FOC_Manager* manager);
void FOC_Manager_GetOutputs(Motor_FOC_Manager* manager, FOCOutputs* outputs);
void FOC_Manager_SaveConfig(Motor_FOC_Manager* manager);
void FOC_Manager_LoadConfig(Motor_FOC_Manager* manager);
void FOC_Manager_TransmitData(Motor_FOC_Manager* manager);
void FOC_Manager_ReceiveData(Motor_FOC_Manager* manager);

#ifdef __cplusplus
}
#endif // __cplusplus


#endif // !_________MOTOR_FOC_MANAGER_H_________
